<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('order_num')->unique()                     ->comment('订单号');
            $table->bigInteger('user_id')           ->default(0)->comment('下单用户');
            $table->decimal('original_price')       ->default(0)->comment('原始价格');
            $table->integer('group_id')             ->default(0)->comment('拼团活动id');
            $table->integer('package_id')           ->default(0)->comment('套餐id');
            $table->integer('coupon_id')            ->default(0)->comment('优惠券id');
            $table->decimal('coupon_reduce_price')  ->default(0)->comment('优惠券减的金额');
            $table->decimal('pay_amount')           ->default(0)->comment('订单实际成交价格');
            $table->timestamp('pay_time')           ->nullable()      ->comment('支付时间');
            $table->string('pay_way')               ->nullable()      ->comment('支付方式：wechatpay,alipay,unionpay,integralpay');
            $table->integer('is_pay')               ->default(0)->comment('是否支付');
            $table->string('remark')                ->default('')->comment('备注');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
